﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace HHHFramework
{


   
    public interface IrefCounter { 
        int RefCount { get; }
        void Retain(object refOnwer =null);
        void Release(object refOnwer = null);
    }
    public class SimpleRC : IrefCounter
    {
        public int RefCount { get; private set; }

        public void Release(object refOnwer = null)
        {
            RefCount--;
            if (RefCount == 0)
            {
                OnZeroRef();
            }
        }
        /// <summary>
        /// 资源引用数增加
        /// </summary>
        /// <param name="refOnwer"></param>
        public void Retain(object refOnwer = null)
        {
            RefCount++;     
        }
        protected virtual void OnZeroRef()
        {

        }
    }
}